package com.qf.dao.Impl;

import com.qf.dao.OrderDetailDao;
import com.qf.domain.OrderDetail;
import com.qf.utils.TxUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

public class OrderDetailDaoImpl implements OrderDetailDao {
    @Override
    public void insert(OrderDetail orderDetail) {
        Connection conn = TxUtils.getConn();
        QueryRunner queryRunner = new QueryRunner();
        String sql = " INSERT INTO `tb_orderdetail` (`id`, `Oid`, `pid`, `num`, `Money`) VALUES (null, ?, ?, ?, ?)";
        try {
            queryRunner.update(conn, sql , orderDetail.getOid(), orderDetail.getPid(), orderDetail.getNum(), orderDetail.getMoney());
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("添加订单失败!!");
        }
    }
}
